﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsSCKiemTraThietBiChiTiet
    {
        private string mDienGiai = "";
        private string mKhoa = "";
        private string mKhoaHangMuc = "";
        private string mKhoaTiepNhan = "";
        private int mTinhTrang = 0;

        public bool Load(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM SC_NoiDungKiemTraLoiThietBi WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTiepNhan = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mKhoaHangMuc = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mTinhTrang = Conversions.ToInteger(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetInt32));
                    this.mDienGiai = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[5];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaTiepNhan", DbType.Int64, ParameterDirection.Input, this.mKhoaTiepNhan);
                commandParameters[2] = DBHelper.createParameter("@KhoaHangMuc", DbType.Int64, ParameterDirection.Input, this.mKhoaHangMuc);
                commandParameters[3] = DBHelper.createParameter("@TinhTrang", DbType.Double, ParameterDirection.Input, this.mTinhTrang);
                commandParameters[4] = DBHelper.createParameter("@DienGiai", DbType.Int64, ParameterDirection.Input, this.mDienGiai);
                flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "SC_sp_NoiDungKiemTraLoiThietBi", commandParameters) > 0;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public string DienGiai
        {
            get
            {
                return this.mDienGiai;
            }
            set
            {
                this.mDienGiai = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaHangMuc
        {
            get
            {
                return this.mKhoaHangMuc;
            }
            set
            {
                this.mKhoaHangMuc = value;
            }
        }

        public string KhoaTiepNhan
        {
            get
            {
                return this.mKhoaTiepNhan;
            }
            set
            {
                this.mKhoaTiepNhan = value;
            }
        }

        public int TinhTrang
        {
            get
            {
                return this.mTinhTrang;
            }
            set
            {
                this.mTinhTrang = value;
            }
        }
    }
}

